package com.tencreat.service.mall.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.mall.MallZone;
import com.tencreat.mapper.mall.MallZoneMapper;
import com.tencreat.service.mall.IMallZoneService;
import org.springframework.stereotype.Service;

/**
 * 专区Service业务层处理
 *
 * @author wangkai
 * @date 2021-11-22
 */
@Service
public class MallZoneServiceImpl extends ServiceImpl<MallZoneMapper, MallZone> implements IMallZoneService {


    /**
     * 查询专区
     *
     * @param id 专区ID
     * @return 专区
     */
    @Override
    public MallZone selectMallZoneById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询专区列表
     *
     * @param mallZone 专区
     * @return 专区
     */
    @Override
    public List<MallZone> selectMallZoneList(MallZone mallZone) {
        return baseMapper.selectList(Wrappers.query(mallZone));
    }

    /**
     * 新增专区
     *
     * @param mallZone 专区
     * @return 结果
     */
    @Override
    public int insertMallZone(MallZone mallZone) {
        mallZone.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallZone);
    }

    /**
     * 修改专区
     *
     * @param mallZone 专区
     * @return 结果
     */
    @Override
    public int updateMallZone(MallZone mallZone) {
        mallZone.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallZone);
    }

    /**
     * 批量删除专区
     *
     * @param ids 需要删除的专区ID
     * @return 结果
     */
    @Override
    public int deleteMallZoneByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除专区信息
     *
     * @param id 专区ID
     * @return 结果
     */
    @Override
    public int deleteMallZoneById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
